import { ColProps } from 'antd';
import { FormLayout } from 'antd/es/form/Form';
import dayjs from 'dayjs';

/*
 * 请求类型
 * */
export const METHOD_TYPE = {
  GET: 'GET',
  POST: 'POST',
  PUT: 'PUT',
  DELETE: 'DELETE',
};

/*
 * 请求前缀
 * */
export const PROJECT_NAME = '/mic';

/*
 * 接口模块
 * */
export const MODULES = {
  AUTH: 'oauth',
  SYSTEM: 'system',
  MICRO: 'micro',
};

/**
 * 菜单code
 */
export const MENU_CODES = {
  MENU: 'menu',
  DICT: 'dict',
  USER: 'user',
  ORG: 'org',
  ROLE: 'role',
  OSS: 'oss',
  DISTRICT: 'district',
  COMMENT: 'comment',
  COMMENT_LIKE: 'commentLike',
};

/**
 * 菜单基本权限
 */
export const AUTH_TYPE = {
  LIST: 'get:/list',
  INSERT: 'post:',
  DELETE: 'delete:',
  UPDATE: 'put:',
  DETAIL: 'get:',
  ALLOT: 'get:/allot', //分配
} as const;

/*
 * 登录页面地址
 * */
export const loginPath = '/login';

/*
 * 是否是开发环境
 * */
export const isDev = process.env.NODE_ENV === 'development';

/*
 * 表单配置
 * */
type FormConfigType = {
  name: string;
  layout: FormLayout;
  colProps: ColProps;
  labelCol: ColProps;
  width: NumStr;
  fieldProps: any;
  isKeyPressSubmit: boolean;
};

export const FORM_CONFIG: Partial<FormConfigType> = {
  name: 'form', //form表单id字段前缀
  layout: 'horizontal',
  colProps: {
    md: 24,
  },
  labelCol: {
    sm: 6,
    md: 4,
    lg: 3,
  },
  isKeyPressSubmit: true, //是否回车提交
  width: '80%',
  // fieldProps: {
  //   className: 'w-full',
  // }
};

/**
 * 定义一个常量对象PAGE_CONFIG，用于配置页面布局。
 *
 * @constant PAGE_CONFIG - 用于存储页面配置的常量对象。
 * @type {Object}
 *
 * @property {Object} header - 页面头部的配置对象。
 * @property {Object} header.breadcrumb - 面包屑导航的配置对象。目前为空，可根据需求扩展。
 */
export const PAGE_CONFIG = {
  header: {
    breadcrumb: {}, //隐藏面包屑
  },
};

/**
 * 表格列宽配置时过滤字段
 */
// export const tableWidthIgnores: (keyof typeof tableWidthMap)[] = [
//   // 'title'
// ]
/**
 * 表格列宽配置,根据字段自动适配,
 */
export const tableWidthMap = {
  createTime: 150,
  updateTime: 150,
  mobile: 120,
  avatar: 70,
  index: 60,
  seq: 70,
  target: 80,
  operationId: 100,
  iconName: 60,
  isShow: 90,
  type: 80,
  // orgId: 80,
  // roleId: 100,
  // title: 150,
  // directorId: 100,
  // value: 100,
  // code: 100,
  // loginName: 80
};

/**
 * date全局配置
 * @type {{minDate: dayjs.Dayjs, maxDate: dayjs.Dayjs}}
 */
export const dateConfig = {
  minDate: dayjs('1970-01-01'),
  maxDate: dayjs(),
};
